<!--suppress HtmlUnknownTag -->
<root xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="rds.html"/>

  <?python
      import os
      from base64 import b64encode
      import turbogears
      from mnemoply import model
      from mnemoply.utils import MonthYear, getBarcodeImage, read_binary_file
      from mnemoply.common_knowledge import month_captions
  ?>

  <report>
    <pages>
      <?python
          objs = [model.Environment.get(int(x)) for x in ids]
          user_id = str(turbogears.identity.current.user.id)
          prefix = model.environment.Environment.getValue('payment_type_admin')
          def get_or_empty(str):
              if str:
                  return str
              return ""
      ?>

      <page py:for="tp in objs">
        <tp py:content="get_or_empty(tp.comment).replace('?', '')"></tp>
        <name py:content="tp.name" ></name>
        <value py:content="tp.value" ></value>
        <?python
            barcode_num = prefix + str(tp.value) + str(user_id).rjust(5, "0")
            barcode_file = getBarcodeImage(barcode_num)
            barcode_b64 = b64encode(read_binary_file("./" + barcode_file))
        ?>
        <barcode_num py:content="'barcode_'+str(barcode_num)"></barcode_num>
        <barcode>
          <filename>${barcode_num}.png</filename>
          <data py:content="barcode_b64"></data>
        </barcode>
      </page>
    </pages>
  </report>

</root>
